package org.logistics.main;

import org.logistics.CarListActivity;
import org.logistics.MainMapActivity;
import org.logistics.R;

import android.os.Bundle;
import android.app.TabActivity;
import android.content.Intent;
import android.view.Menu;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;

public class LoginMainActivity extends TabActivity implements
OnCheckedChangeListener {
	
	//选择导航栏
	private TabHost tabHost ;
	//选择组
	private RadioGroup radioGroup;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login_main);
		
		tabHost = getTabHost();
		
		tabHost.addTab(tabHost.newTabSpec("map").setIndicator("map").
				setContent(new Intent (this , MainMapActivity.class)));
		tabHost.addTab(tabHost.newTabSpec("list").setIndicator("list").
				setContent(new Intent (this , CarListActivity.class)));
//		tabHost.addTab(tabHost.newTabSpec("help").setIndicator("help").
//				setContent(new Intent (this , MainMapActivity.class)));
		
		radioGroup =  (RadioGroup) findViewById(R.id.main_radio);
		radioGroup.setOnCheckedChangeListener(this);
		
	}
	

	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.login_main, menu);
		return true;
	}

	@Override
	public void onCheckedChanged(RadioGroup group, int checkedId) {
		switch (checkedId) {
		case R.id.map:
			tabHost.setCurrentTabByTag("map");
			break;
		case R.id.list:
			tabHost.setCurrentTabByTag("list");
			break;
		case R.id.help:
			tabHost.setCurrentTabByTag("help");
			break;
		default:
			tabHost.setCurrentTabByTag("map");
		}
		
	}

}
